<?php

class lwn_VerifyAction extends IntesysAction
{

    public function __construct($config = array())
    {
        import('@.ORG/Sms/toMsg');
    }

    public function index()
    {
        if (IS_POST) {
            $contrast = new toMsg();
            $result = $contrast->contrast();
            dump($result);
        }
        $this->display();
    }

    public function checkcode()
    {
        $contrast = new toMsg();
        $result = $contrast->contrast();
        return $result;
    }

    public function who($sql = 'Member')
    {
        $member = M($sql)->where('site_id = ' . __SITEID__ . ' and username like "' . $_POST['username'] . '"')->find();
        session('memberInfo', $member);
        if ($member != null) {
            $info = true;
        } else {
            
            $info['status'] = 1;
            $info['error'] = '没有这个用户';
            $info['url'] = '';
        }
        
        return $info;
    }

    public function editpass($sql = 'Member')
    {
        $memberInfo = session('memberInfo');
        
        if ($memberInfo == null) {
            $this->error('修改失败，请重新修改');
        }
        $pd['password'] = md5($_POST['password']);
        
        $member = M($sql)->where('site_id = ' . __SITEID__ . ' and username like "' . $memberInfo['username'] . '" ')->save($pd);
        
        return $member;
    }

    public function send($tag = NULL, $type = tel, $sql = 'Member')
    {
        $check = $this->who();
        
        if (is_array($check)) {
            echo json_encode($check);
            exit();
        }
        
        if ($_GET['tel'] != null) {
            $tag = $_GET['tel'];
        }
        if ($_POST['tel'] != null) {
            $tag = $_POST['tel'];
        }
        
        $sand = new toMsg();
        $info = $sand->start($tag, $type, $sql);
        echo json_encode($info);
    }
}

